package com.bkhc.business.api;

import com.bkhc.business.entity.Customer;
import com.bkhc.business.entity.Group;
import com.bkhc.business.service.BusinessService;
import com.bkhc.business.service.CustomerService;
import com.bkhc.common.annotation.ApiOperation;
import com.bkhc.common.annotation.ApiPackage;
import com.bkhc.common.annotation.AuditLog;
import com.bkhc.common.annotation.WebRestController;
import com.bkhc.common.enu.OperationEnum;
import com.bkhc.common.util.response.ResultJson;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * @author pcq
 * @date 2021/6/20 17:57
 */
@WebRestController
@Api("客户管理服务")
@ApiPackage(code="business-api",name="客户管理服务",description = "后台客户管理服务操作接口")
public class CustomerController extends CommonController {
    @Autowired
    private CustomerService customerService;

    @ApiOperation(code="queryCustomerByAdmin",name="查找所有客户",description = "查找所有客户")
    @AuditLog(object="Customer",operation = "查找所有客户",type = OperationEnum.query)
    @RequestMapping(path = "/customer",method = RequestMethod.POST)
    public ResultJson<?> queryCustomerByAdmin(@RequestBody(required = false) Customer customer,
                                              @RequestParam(name="pageIndex") int pageIndex,
                                              @RequestParam(name="pageSize") int pageSize) {
        ResultJson<?> res = customerService.queryCustomerByAdmin(customer, pageIndex, pageSize);
        return res;
    }

    @ApiOperation(code="assignmentToManage",name="分配客户给业务合伙人",description = "分配客户给业务合伙人")
    @AuditLog(object="Customer",operation = "分配客户给业务合伙人",type = OperationEnum.update)
    @RequestMapping(path = "/customer/assignment",method = RequestMethod.POST)
    public ResultJson<?> assignmentToManage(@RequestBody(required = true) Customer customer) {
        ResultJson<?> res = customerService.assignmentToManage(customer);
        return res;
    }
    @ApiOperation(code="settingIdentity",name="设置客户身份",description = "设置客户身份")
    @AuditLog(object="Customer",operation = "设置客户身份",type = OperationEnum.update)
    @RequestMapping(path = "/customer/identity/setting",method = RequestMethod.POST)
    public ResultJson<?> settingIdentity(@RequestBody(required = true) Customer customer) {
        ResultJson<?> res = customerService.settingIdentity(customer);
        return res;
    }

    //@ApiOperation(code="getCustomerIdentity",name="查询客户身份",description = "查询客户身份",type = "common")
    @AuditLog(object="Customer",operation = "查询客户身份",type = OperationEnum.update)
    @RequestMapping(path = "/customer/getCustomerIdentity",method = RequestMethod.GET)
    public ResultJson<?> getCustomerIndentity(@RequestParam(name="userId") String userid) {
        ResultJson<?> res = customerService.queryCustomerByUserId(userid);
        return res;
    }

    @ApiOperation(code="assignmentToPerson",name="分配客户给业务员",description = "分配客户给业务员")
    @AuditLog(object="Customer",operation = "分配客户给业务员",type = OperationEnum.update)
    @RequestMapping(path = "/customer/assignmentToPerson",method = RequestMethod.POST)
    public ResultJson<?> assignmentToPerson(@RequestBody(required = true) Customer customer) {
        ResultJson<?> res = customerService.assignmentToPerson(customer);
        return res;
    }
}
